package com.fang.excel.controller;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CachedThreadPoolExample {
    public static void main(String[] args) {
        ExecutorService executor = Executors.newCachedThreadPool();

        for (int i = 0; i < 10000000; i++) {
            int taskNumber = i;
            executor.execute(() -> {
                System.out.println("任务 " + taskNumber + " 由线程 " + Thread.currentThread().getName() + " 执行");
            });
        }

        executor.shutdown(); // 关闭线程池
    }
}
